# known_person.py - 熟人处理模块
from datetime import datetime
import random
from untils.tts import play
# 问候语库
greetings = [
    "欢迎！今天过得怎么样？",
    "很高兴见到您！需要我为您做些什么吗？",
    "您好！有什么可以帮您的吗？",
]

# 时间相关建议
time_suggestions = {
    "morning": ["记得吃早餐哦！", "今天天气不错，适合晨练！", "别忘了今天的重要会议！"],
    "afternoon": ["午餐时间到了！", "下午茶时间，休息一下吧！", "记得完成今天的工作任务！"],
    "evening": ["晚餐时间到了！", "晚上放松一下，看部电影吧！", "记得早点休息，明天还有重要的事情！"],
    "night": ["时间不早了，早点休息吧！", "晚安，祝您好梦！", "睡前记得关闭所有电器！"]
}

def get_time_of_day():
    """获取当前时间段"""
    hour = datetime.now().hour
    if 5 <= hour < 12:
        return "morning"
    elif 12 <= hour < 18:
        return "afternoon"
    elif 18 <= hour < 22:
        return "evening"
    else:
        return "night"

def generate_greeting(name):
    """生成问候语"""
    # 基本问候
    greeting = random.choice(greetings)
    
    # 添加个性化
    personalized_greeting = f"{name}，{greeting}"
    
    # 添加时间建议
    time_of_day = get_time_of_day()
    time_suggestion = random.choice(time_suggestions[time_of_day])
    personalized_greeting += f" {time_suggestion}"
    
    return personalized_greeting

def speak(text):
    play(text)

def handle_known_person(name):
    """处理已知人员"""
    print(f"开始处理已知人员: {name}")
    
    # 生成并播放问候语
    greeting = generate_greeting(name)
    speak(greeting)
    print(f"已知人员处理完成: {name}")